package escritorio.conn;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import escritorio.javaBeans.Custas;

public class CustaDao {
	private Connection conn;

	public CustaDao() {
		super();
		this.conn = new ConnectionFactory().getConnection();
	}

	public void insereCustas(Custas custa) {
		String sql = "insert into custas " + "(data,descricao,valor)"
				+ " Values (?,?,?)";
		try {
			PreparedStatement stmt = conn.prepareStatement(sql);
			stmt.setDate(1, new Date(custa.getData().getTimeInMillis()));
			stmt.setString(2, custa.getDescricao());
			stmt.setDouble(3, custa.getValor());
			stmt.execute();
			stmt.close();
		} catch (SQLException e) {
			throw new ConnErro(null, e);
		}
	}
}
